package com.yibai.web.app.controller;

import com.yibai.web.app.service.ArticleService;
import com.yibai.web.dto.ArticleInfoRequest;
import com.yibai.web.dto.ArticleListRequest;
import com.yibai.web.dto.ArticleRequest;
import com.yibai.web.dto.SuperResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author fang
 * @since 2021-04-19
 */
@RestController
@RequestMapping("/app/article")
@Api(value = "文章管理",tags = {"文章管理"})
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    @PostMapping("/list")
    @ApiOperation(value = "文章列表" ,notes = "")
    public SuperResponse list(@Valid @RequestBody ArticleListRequest request ){
        return articleService.list(request);
    }

    @PostMapping("/info")
    @ApiOperation(value = "文章详情" ,notes = "")
    public SuperResponse add(@Valid @RequestBody ArticleRequest request ){
        return articleService.info(request);
    }

    @PostMapping("/add")
    @ApiOperation(value = "文章添加" ,notes = "")
    public SuperResponse add(@Valid @RequestBody ArticleInfoRequest request ){
        return articleService.add(request);
    }

    @PostMapping("/delete")
    @ApiOperation(value = "文章删除" ,notes = "")
    public SuperResponse delete(@Valid @RequestBody ArticleRequest request ){
        return articleService.delete(request);
    }

    @PostMapping("/update")
    @ApiOperation(value = "文章修改" ,notes = "")
    public SuperResponse update(@Valid @RequestBody ArticleInfoRequest request ){
        return articleService.update(request);
    }


}

